import PlayerControl from "./PlayerControl";

const {ccclass, property} = cc._decorator;

@ccclass
export default class EnemyFireControl extends cc.Component {
    //获得组件刚体
    EnemyRigi:cc.RigidBody
    //子弹速度
    Speed:number = 60;

    start () {
        this.EnemyRigi = this.node.getComponent(cc.RigidBody);
        //当前角度转弧度
        let CurrentRad = cc.misc.degreesToRadians(this.node.angle);
        //弧度转向量
        let rotateV2 = cc.v2(0,1).rotate(-CurrentRad);
        //子弹移动
        this.EnemyRigi.linearVelocity = cc.v2(rotateV2.x * this.Speed, -rotateV2.y * this.Speed);
    }

    onBeginContact(concat,slef,other) {
        if (other.tag == 0) {
            other.getComponent(PlayerControl).died();
        }
        this.node.destroy();
    }
    // update (dt) {}
}
